package com.yimo.config;

import com.yimo.interceptor.CrawlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import javax.annotation.Resource;

@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
	@Resource
	private CrawlerInterceptor crawlerInterceptor;


	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("swagger-ui.html")
				.addResourceLocations("classpath:/META-INF/resources/");
		registry.addResourceHandler("/webjars/**")
				.addResourceLocations("classpath:/META-INF/resources/webjars/");
	}
	@Override
	public void addInterceptors(InterceptorRegistry registry) {

		registry.addInterceptor(crawlerInterceptor).addPathPatterns("/**/*");
		super.addInterceptors(registry);
	}
}
